package fr.alesia.deepstack.stat.simple;

import java.util.Comparator;
import java.util.Map;

import fr.alesia.deepstack.bean.Player;

public class PlayerComparator implements Comparator<Player> {

	private Map<Player, Integer> players;
	
	public PlayerComparator(Map<Player, Integer> players) {		
		this.players = players;
	}

	public int compare(Player p1, Player p2) {
		
		int n1 = players.get(p1);
		int n2 = players.get(p2);
		return (n2 - n1 == 0 ? p1.getName().compareTo(p2.getName()) : n2 - n1);
	}
}
